<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>红包编辑</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}"
          rel="stylesheet">
    <!-- Morris -->
    <link href="../../resource/hotui/css/plugins/morris/morris-0.4.3.min.css"
          th:href="@{/resource/hotui/css/plugins/morris/morris-0.4.3.min.css}" rel="stylesheet">
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>
</head>

<body>
<form id="saveForm">
    <div class="wrapper wrapper-content tooltip-demo" style="max-height: 492px; overflow-y: auto;">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins m-b-none">
                    <div class="ibox-content p-xxs no-borders" style="border-top: none;">
                        <div class="panel-body good-edit-failure form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">红包名称:</label>

                                <div class="col-sm-10">
                                    <input type="text" required class="form-control  m-b-none" id="edit_title"
                                           placeholder="红包名称"/>
                                </div>
                            </div>
                            <div class="hr-line-dashed "></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">红包类型:</label>

                                <div class="col-sm-10">
                                    <select style="width: auto;" class="form-control input-s-sm" id="edit_type">
                                        <option value="0">普通红包</option>
                                        <option value="1">随机红包</option>
                                    </select>
                                </div>
                            </div>
                            <div class="hr-line-dashed "></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">红包金额:</label>
                                <div class="col-sm-4 form-inline">
                                    <input type="text" class="form-control input-s-sm m-b-none" required max="5" min="0"
                                           id="edit_amount" th:attr="max=${balance}"
                                           placeholder="金额"/>

                                    <p class="form-control-static">当前余额：<span id="edit_balance"
                                                                              th:text="${balance}"></span></p>
                                </div>
                            </div>
                            <div class="hr-line-dashed "></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">红包个数:</label>
                                <div class="col-sm-10">
                                    <input name="price" id="edit_num" type="text" required
                                           class="form-control input-s-sm only-num" placeholder="红包个数">
                                </div>
                            </div>
                            <div class="hr-line-dashed "></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">开抢时间:</label>

                                <div class="col-sm-10">
                                    <div style="width: 200px" class='input-group date'>
                                        <input type="text" readonly class="form-control input-sm m-b-none"
                                               id="edit_startTime"
                                               placeholder="开抢时间"
                                               onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-calendar"></span>
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row" style="padding: 0 15px; position: absolute; bottom: 0; width: 100%;">
        <div class="col-lg-12">
            <div class="ibox float-e-margins" style="margin-bottom: 0;">
                <div class="ibox-title" style="padding: 0; min-height: initial;">
                    <div class="form-group " style="float: right;">
                        <button type="submit" class="btn btn-primary">保存</button>
                        <button type="submit" class="btn btn-white m-l" onclick="javascript:parent.layer.close(index);">
                            关闭
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
<script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
<script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js(123123)}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js"></script>
<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>
<script src="../../resource/hotui/js/plugins/validate/jquery.validate.min.js"
        th:src="@{/resource/hotui/js/plugins/validate/jquery.validate.min.js}"></script>
<script src="../../resource/hotui/js/plugins/validate/messages_zh.min.js"
        th:src="@{/resource/hotui/js/plugins/validate/messages_zh.min.js}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-validate.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-validate.js}"></script>
<script src="../../resource/lib/My97DatePicker/WdatePicker.js"
        th:src="@{/resource/lib/My97DatePicker/WdatePicker.js}"></script>

<script type="text/javascript" th:inline="javascript">
    var apiUri = /*[[@{/marketing/redPacket}]]*/ "";
</script>

<script type="text/javascript">
    var index = parent.layer.getFrameIndex(window.name);

    $("#saveForm").validateCallback(function () {
        let title = $("#edit_title").val();
        let type = $("#edit_type").val();
        let amount = $("#edit_amount").val();
        let num = $("#edit_num").val();
        let startTime = $("#edit_startTime").val();

        let requestData = {
            title: title,
            type: type,
            amount: amount,
            num: num,
            startTime: startTime
        };

        hot.ajax(apiUri + "/edit", requestData, function (apiResult) {
            if (apiResult.resultCode === 2000) {
                hot.tip.success("保存成功", function () {
                    parent.location.reload();
                    parent.layer.close(index);
                });
            } else {
                hot.tip.error("保存失败--" + apiResult.resultMsg);
            }
        }, function () {
        }, "post", 300);
    });
</script>
</body>

</html>
